package com.tianbing.adlottery.helper;

import com.jubao.ejb.business.ProductBusiness;
import com.jubao.ejb.business.StoreBusiness;
import com.jubao.ejb.business.util.BusinessConstant;
import com.jubao.ejb.dao.ProductDao;
import com.jubao.ejb.dao.StoreDao;

public class RankingWorker {

	private StoreBusiness siteBusiness;

	private ProductBusiness contentBusiness;

	private StoreDao siteDao;

	private ProductDao contentDao;

	int batchSize = 10;

	int maxCategoryMember = 100;

	public void setContentBusiness(ProductBusiness contentBusiness) {
		this.contentBusiness = contentBusiness;
	}

	public void setContentDao(ProductDao contentDao) {
		this.contentDao = contentDao;
	}

	/**
	 * used by Spring Schedule Job Schedule job will rearrange the store's
	 * ranking membership of category
	 * 
	 */
	public void rankingStores() {
		Integer[] siteTypeIds = { BusinessConstant.Type.SITE_STORE.getId() };
//		List<Store> stores = siteDao.getListSiteBy(siteTypeIds, null, 0, batchSize, "s.lastRankedDate ASC");
//		for (Store store : stores) {
//			siteBusiness.rankingSite(store.getSysId(), maxCategoryMember);
//		}
	}

	public void rankingWebSites() {
		Integer[] siteTypeIds = { BusinessConstant.Type.SITE_WEBSITE.getId() };
//		List<Store> stores = siteDao.getListSiteBy(siteTypeIds, null, 0, batchSize, "s.lastRankedDate ASC");
//		for (Store store : stores) {
//			siteBusiness.rankingSite(store.getSysId(), maxCategoryMember);
//		}
	}

	public void rankingProducts() {
		Integer[] contentTypeIds = { BusinessConstant.Type.CONTENT_PRODUCT.getId() };
		//		List<Product> products = contentDao.getListContentBy(contentTypeIds, null, null, 0, batchSize,
		//				"c.lastRankedDate ASC");
		//		for (Product product : products) {
		//			contentBusiness.rankingContent(product.getSysId(), maxCategoryMember);
		//		}
	}

	public void setSiteBusiness(StoreBusiness siteBusiness) {
		this.siteBusiness = siteBusiness;
	}

	public void setSiteDao(StoreDao siteDao) {
		this.siteDao = siteDao;
	}

	public void setBatchSize(int batchSize) {
		this.batchSize = batchSize;
	}

	public void setMaxCategoryMember(int maxCategoryMember) {
		this.maxCategoryMember = maxCategoryMember;
	}
}
